package com.yanle.pattern.singleton;

/**
 * @Description: 双重校验锁单例模式
 * @Author Richard
 * @Date 2018/4/11 15:35
 */
public class VolatileSingleton {

    private volatile static VolatileSingleton instance;

    private VolatileSingleton() {
    }

    public static VolatileSingleton getInstance() {
        if (null == instance) {
            synchronized (VolatileSingleton.class) {
                if (null == instance) {
                    instance = new VolatileSingleton();
                }
            }
        }
        return instance;
    }

}
